function TreeNode(obj){
   this.parent = obj.parent;
   this.childs = obj.childs || [];
   this.data = obj.data || '';
   this.selfElement = obj.selfElement;//访问对应的dom节点
   this.selfElement.TreeNode = this;//对应的dom节点访问回来
}

TreeNode.prototype = {
   constructor:TreeNode,
   // 改变箭头、可见性、高亮、普通
   render:function(arrow,visibility,toHeight,deHightlight){
     if(arguments.length<3){
        toHeight = false;
        deHightlight = false;
     }

     //控制箭头状态   
     if(arrow){
        if(this.isLeaf()){//是个叶节点，设置为空
           this.selfElement.getElementsByClassName('arrow')[0].className = 'arrow empty-arrow';
        }else if(this.isFolded()){//折叠状态 向右
           this.selfElement.getElementsByClassName('arrow')[0].className = 'arrow right-arrow';
        }else{//展开向下
           this.selfElement.getElementsByClassName('arrow')[0].className = 'arrow down-arrow';
        }
     }

     //显示隐藏状态
     if(visibility){//可见
        if(this.selfElement.className.indexOf('nodebody-visible') == -1){
           this.selfElement.className = this.selfElement.className.replace('hidden','visible');
        }else{//不可见
         this.selfElement.className = this.selfElement.className.replace('visible','hidden');
        }
     } 
     
    
     if(toHeight){ //设置高亮
      this.selfElement.getElementsByClassName("node-title")[0].className = "node-title node-title-highlight";
     }

     if(deHightlight){//取消高亮
      this.selfElement.getElementsByClassName("node-title")[0].className = "node-title";
     }
   },
   // 删除节点，dom会自动递归删除子节点，TreeNode递归手动删除子节点
   deleteNode:function(){

   },
   addChild:function(){//增加节点

   },
   toggleFold:function(){//展开收拢

   },
   isLeaf:function(){//是否为叶节点
      return this.childs.length == 0
   },
   isFolded:function(){//是否处于折叠状态

   }
}

// 创建根节点对应的TreeNode对象
var root = new TreeNode({parent:null,childs:[],data:'前端工程师',selfElement:document.getElementsByClassName('nodebody-visible')[0]});
// 为root绑定事件代理，处理所有节点的点击事件

